<template>
  <transition name="modal">
    <div class="yk-modal" v-if="isModal">
      <div class="yk-model-head">
        <div class="model-name">{{ props.title }}</div>
        <span class="iconfont icon-guanbi" @click="clooseModal()"></span>
      </div>
      <slot></slot>
    </div>
  </transition>
</template>

<script setup>
import { defineProps, defineEmits } from "vue";
const props = defineProps({
  title: {
    default: "标题",
  },
  isModal: {
    default: false,
  },
});
const emit = defineEmits(["cloose"]);

function clooseModal() {
  emit("cloose", "我是关闭");
}
// onMounted(clooseModal);
props;
</script>

<style lang="scss" scoped>
.modal {
  //入场
  &-enter {
    &-from {
      transform: translateX(360px);
    }
    &-active {
      transition: all 0.4s ease-out;
    }
    &-to {
      transform: translateX(0);
    }
  }
  //出
  &-leave {
    &-from {
      transform: translateX(0);
    }
    &-active {
      transition: all 0.4s ease-in;
    }
    &-to {
      transform: translateX(360px);
    }
  }
}
.yk-modal {
  width: 360px;
  height: 100%;
  position: fixed;
  right: 0;
  top: 52px;
  z-index: 1000;
  background: rgba($color: #fff, $alpha: 0.8);
  box-shadow: 0 0 20px 0 rgba($color: #000, $alpha: 0.08);
  backdrop-filter: blur(20px);
  padding: 20px;
  .yk-model-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .model-name {
      font-size: 16px;
      color: #202020;
      font-weight: 600;
    }
    .icon-guanbi {
      color: #5b5b5b;
      cursor: pointer;
    }
  }
}
</style>